// 注册功能
const register = document.querySelector('#btn-register')
console.log(register)
register.addEventListener('click', function () {
    const form = document.querySelector('#reg-form')
    const email = document.querySelector('#input-email').value
    const pwd = document.querySelector('#input-password').value
    if (email.length === 0 || pwd.length === 0) return alert('账号和密码不能为空')
    const data = serialize(form)
    axios.post('/register', data)
        .then(({ data }) => {
            console.log(data)
            if (data.message === '注册成功') {
                // console.log(data.message)
                tip(data.message)
                // 注册成功后跳转到登录页面
                location.href = '/login.html'
            } else {
                console.log(data.message)
            }
        })
        .catch(err => {
            // console.log(err.response)
            tip(err.response.data.message)
        })
})